package com.morningstar.qs.basic.db.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.morningstar.qs.basic.db.bean.Component;

public class ComponentDto extends Component implements Serializable {
	private static final long serialVersionUID = -7831028473732599856L;

	public ComponentDto() {
		super();
	}

	private List<FunctionInfoDto> functions;
	private ComponentDto parentComp;
	private List<ComponentDto> subComponents;

	public List<ComponentDto> getSubComponents() {
		return subComponents;
	}

	public void addSubComponent(ComponentDto cd) {
		if (subComponents == null)
			subComponents = new ArrayList<ComponentDto>();
		subComponents.add(cd);
	}

	public void setSubComponents(List<ComponentDto> subComponents) {
		if (subComponents == null)
			return;
		if (this.subComponents != null)
			this.subComponents.addAll(subComponents);
		else
			this.subComponents = new ArrayList<ComponentDto>(subComponents);
	}

	public List<FunctionInfoDto> getFunctions() {
		if (functions != null)
			return new ArrayList<FunctionInfoDto>(functions);
		else
			return null;
	}

	public void addFunction(FunctionInfoDto fid) {
		if (this.functions == null)
			functions = new ArrayList<FunctionInfoDto>();
		functions.add(fid);
	}

	public void setFunctions(List<FunctionInfoDto> functions) {
		if (functions == null)
			return;

		if (this.functions != null)
			this.functions.addAll(functions);
		else
			this.functions = new ArrayList<FunctionInfoDto>(functions);

	}

	public ComponentDto getParentComp() {
		return parentComp;
	}

	public void setParentComp(ComponentDto parentComp) {
		this.parentComp = parentComp;
	}

}
